package grouup3_project4;

import javax.swing.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Person implements ActionListener
{

	public String firstName, lastName;
	public int age;
	private String ssn;	
	static Person p;
	private JFrame frame = new JFrame("Person");
	
	public void createPerson()
	{
		frame.setLayout(new GridLayout(5,2));
		frame.setVisible(true);
		
		frame.add(new JLabel("First Name: "));
		final JTextArea firstNameTextArea = new JTextArea(); 		
		frame.add(firstNameTextArea);
		
		frame.add(new JLabel("Last Name: "));
		final JTextArea lastNameTextArea = new JTextArea();
		frame.add(lastNameTextArea);
		
		frame.add(new JLabel("Age: "));
		final JTextArea ageTextArea = new JTextArea();
		frame.add(ageTextArea);
		
		frame.add(new JLabel("SSN: "));
		final JTextArea ssnTextArea = new JTextArea();
		frame.add(ssnTextArea);
		
		
		JButton submit = new JButton("Submit");
		submit.addActionListener(new ActionListener() 
		{	
			@Override
			public void actionPerformed(ActionEvent e) 
			{
				int age = Integer.parseInt(ageTextArea.getText());			
				p = new Person(firstNameTextArea.getText(), lastNameTextArea.getText(), age, ssnTextArea.getText()); 		
			}
		});
		frame.add(submit);
		
		
		JButton cancel = new JButton("Cancel");
		cancel.addActionListener(new ActionListener() 
		{	
			@Override
			public void actionPerformed(ActionEvent e) 
			{
				frame.dispose(); 			
			}
		});
		
		
		frame.add(cancel);
		frame.pack();
	}
	
	
	
	
	public Person()
	{		
	}	
	public Person(String firstName, String lastName, int age, String ssn)
	{
		this.firstName = firstName;
		this.lastName = lastName;
		this.age = age;
		this.ssn = ssn;
		System.out.println(this);
	}
	public String getSsn()
	{
		return this.ssn;
	}	
	public void setSsn(String ssn)
	{
		this.ssn = ssn;
	}
	

	
	
	
	
	@Override
	public String toString()
	{
		return "First Name: " + this.firstName + "\nLastName: " + this.lastName + "\nAge: " + this.age + "\nSSN: " + this.ssn; 
	}
	@Override
	public void actionPerformed(ActionEvent e) 
	{
		System.exit(0);
	}
}

